package com.dss.code_generation.controller;

import com.alibaba.fastjson.JSONObject;
import com.dss.code_generation.service.IYapiService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 成研swagger接口转yapi
 * @Description: 获取接口参数描述
 * @author: dongshoushan
 * @date: 2021年11月18日 15:50
 */
@RestController
@RequestMapping("/swagger")
@Api(tags = "01: 接口文档处理")
public class YapiController {
    @Resource
    private IYapiService yapiService;
    /**
     * 根据实体类获取接口文档Yapi的所需json参数
     * @return
     */
    @GetMapping("/getByDto")
    @ApiOperation(value = "根据实体类获取接口文档Yapi的所需json参数",notes = "根据实体类获取接口文档Yapi的所需json参数")
    public JSONObject getByDto(@RequestParam(value = "name") String name,
                               @RequestParam(value = "type")
                               @ApiParam(value = "类型:0入参单个对象 1出参单个对象 2出参List 3出参分页对象",defaultValue = "1") String type){
        return yapiService.getByDto(name,type);
    }
}
